package 力扣日常刷题.木23一月.第16天316;

import 力扣日常刷题.TreeNode;

/**
 * @author 帅小伙
 * @date 2022/3/16
 * @description
 */
public class Demo87对称二叉树 {

    public boolean isSymmetric(TreeNode root) {
        if(root == null) return true;
        return isSymmetric(root,root);
    }

    public  boolean isSymmetric(TreeNode a, TreeNode b) {
        if(a == null && b == null) return true;
        if(a == null || b == null || a.val != b.val) return false;
        return isSymmetric(a.right,b.left) && isSymmetric(a.left,b.right);
    }

}
